import indexModel from '../../models/indexModel'

export const getSwiperData = () => dispatch => {
  // swiper
  indexModel.getSwiper().then(ret => {
    dispatch({
      type: 'setSwiper',
      payload: ret.data.data
    })
  })
}
export const getSwiperData2 = () => dispatch => {
  // swiper
  indexModel.getSwiper2().then(ret => {
    dispatch({
      type: 'setSwiper2',
      payload: ret.data.data
    })
  })
}

export const getRecommendData = (page) => dispatch => {
  //今日推荐
  indexModel.getRecommend(page).then(ret => {
    dispatch({
      type: 'setRecommend',
      payload: ret
    })
  })
}
  //榜单
  export const getListData = () => dispatch => {
    indexModel.getList().then(ret => {
      dispatch({
        type: 'setList',
        payload: ret.data.data
      })
    })
}

export const getRecommendData2 = () => dispatch => {
  //今日推荐
  indexModel.getRecommend2().then(ret => {
    dispatch({
      type: 'setRecommend2',
      payload: ret.data.data
    })
  })
}
//追漫
export const getCartoonData = () => dispatch => {
  // 网络请求
  indexModel.getCartoon().then(ret => {
    dispatch({
      type: 'setCartoon',
      payload: ret.data.data
    })
  })
}

//详情
export const getDetailData = () => dispatch => {
  // 网络请求
  indexModel.getDetail().then(ret => {
    dispatch({
      type: 'setDetail',
      payload: ret.data.data
    })
  })
}

//书架
export const getDetailData2 = (id) => dispatch => {
  // 网络请求
  indexModel.getDetail2(id).then(ret => {
    dispatch({
      type: 'setDetail2',
      payload: ret
    })
  })
}
